<template>
<transition
:css="false"
@enter="enter"
@leave="leave"
>
  <div class="mini-player" v-show="this.isMiniPlayer">
    <div class="player-warpper">
        <div class="player-left" @click="showMiniPlay">
            <img :src=currentSong.picUrl ref="cd">
            <div class="player-title">
                <h3>{{currentSong.name}}</h3>
                <p>{{currentSong.singer}}</p>
            </div>
        </div>
        <div class="player-right">
            <div class="play" @click="play" ref="play"></div>
            <div class="list" @click.stop="showList"></div>
        </div>
    </div>
  </div>
</transition>
</template>

<script>
import { mapGetters,mapActions } from 'vuex'
import Velocity from 'velocity-animate'
import 'velocity-animate/velocity.ui'
export default {
  name: 'MiniPlayer',
  computed:{
      ...mapGetters([
          'isMiniPlayer',
          'isPlaying',
          'currentSong'

      ])
  },
  methods: {
      ...mapActions([
          'setFullScreent',
          'setMiniPlayer',
          'setIsPlaying',
          'setListPlayer'
      ]),
      showList(){
        //   this.$emit('showList')
        this.setListPlayer(true)
      },
      showMiniPlay(){
          this.setFullScreent(true)
          this.setMiniPlayer(false)
      },
      play(){
          this.setIsPlaying(!this.isPlaying)
      },
      enter(el,done){
      Velocity(el,'transition.bounceUpIn',{ duration:500 },function(){
        done()
      })
    },
      leave(el,done){
      Velocity(el,'transition.bounceDownOut',{ duration:500 },function(){
        done()
      })
    }
  },
  watch:{
      isPlaying(newValue,oldValue){
          if(newValue){
            this.$refs.play.classList.add('active')
            this.$refs.cd.classList.add("active")
          }else{
            this.$refs.play.classList.remove('active')
            this.$refs.cd.classList.remove("active")
          }
      }
  }
}
</script>

<style scoped lang="scss">
@import '../../assets/css/variable.scss';
@import '../../assets/css/mixin.scss';
.mini-player{
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 150px;
    .player-warpper{
        width: 100%;
        height: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        @include bg_color();
        .player-left{
            display: flex;
            padding-left: 30px;
            img{
            width: 100px;
            height: 100px;
            border-radius: 50%;
            margin-right: 20px;
            animation: spot 5s linear infinite;
            animation-play-state: paused;
            &.active{
                  animation-play-state: running;
                }
            }
            .player-title{
                display: flex;
                flex-direction: column;
                justify-content: center;
                // align-items: center;
                h3{
                    @include font_size($font_medium);
                    @include font_color();
                }
                p{
                    @include font_size($font_medium_s);
                    @include font_color();
                }
            }
        }
        .player-right{
            display: flex;
            align-items: center;
            .play{
                width: 84px;
                height: 84px;
                @include bg_img('../../assets/images/play');
                &.active{
                    @include bg_img('../../assets/images/pause');
                }
            }
            .list{
                width: 120px;
                height: 120px;
                @include bg_img('../../assets/images/list')
            }
        }
    }
}
@keyframes spot{
    from{
        transform: rotate(0deg)
    }
    to{
        transform: rotate(360deg)
    }
}
</style>
